<html>
<head>
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p class="heading">
 Cookie Object (last update 12/05/01)
</p>
<p class="subheading">
Description:
</p>
<p>
The core library includes the cookie object constructor. Cookies are small data storage
containers in the visitor's browser, a little like files. You can use up to 20 cookies
per visitor. A cookie must have a unique name assigned to it (like a file), you do this
when you create the cookie object. If a cookie with the name you use already exists,
then your cookie object will have it's value set to whatever you set it to the last time
the visitor was at your site. If not, the cookie's initial value will be null.
</p>
<p>
Cookies are easy to use with the gamelib library. To simplify things for games use,
expiry dates and paths etc are not used. Any cookie you create will not expire between
browser sessions, and must be erased using the erase() method. You simply create, read,
set and erase the cookie just as you would a file.
</p>


<p class="subheading">
To use:
</p>
<p>
The cookie code is part of the <a href="coredoc.html">core module</a>. So is linked in to your script when you add the
core (as you always will when using gamelib):
</p>
<p class="jcode">
&lt;script language="Javascript" src="gamelib_core.js"&gt;&lt;/script&gt;
</p>
<p>
You then create a cookie object by passing the "filename" as so:
</p>
<p class="jcode">
var mycookie=new Gl_cookie("visitor_name");
</p>
<p>
If you had a cookie with the filename "visitor_name" some time previously, it will hold the value it did the
last time it was used. The instance name (in this case "mycookie") is simply a way of using the file. Cookies
can only hold simple data - either Strings or Numbers, NOT arrays or Objects.
</p>
<p class="subheading">
List of methods for cookies
</p>

<p>
<a href="#erase">erase</a><br>
<a href="#setValue">setValue</a><br>
</p>

<p class="subheading">
List of properties for cookies
</p>

<p>
<a href="#value">value</a><br>
</p>


<p class="subheading">
Descriptions of methods
</p>

<table>
<tr>
<th>Method</th><th NOWRAP>Parameters</th><th>Description</th>
</tr>

<tr>
<a name="erase">
<td>erase</td><td>(none)</td><td>Erase the cookie. After this, the cookie will no longer exist</td>
</tr>
<tr>
<a name="setValue">
<td>setValue</td><td>String/Numeric</td><td>The argument to this method is the data you wish the cookie to hold. When you add new data to a cookie, it loses its old data</td>
</tr>

</table>


<p class="subheading">
Descriptions of properties
</p>

<table>
<tr>
<th>Property</th><th NOWRAP>Data Type</th><th NOWRAP>Read/Write</th><th>Description</th>
</tr>
<tr>
<a name="value">
<td>value</td><td>String/Numeric</td><td>R</td><td>The current contents of the cookie. This is the data saved between page visits</td>
</tr>

</table>


</body>
</html>